import pandas as pd
orig_df = pd.read_csv('https://github.com/gopalkoduri/flisound/blob/master/data/Ratings_Warriner_et_al.csv?raw=true', index_col=0)
orig_df.to_csv('Ratings_Warriner_et_al.csv', index=False)
df = pd.read_csv('Ratings_Warriner_et_al.csv')
df
Word | V.Mean.Sum | V.SD.Sum | V.Rat.Sum | A.Mean.Sum | A.SD.Sum | A.Rat.Sum | D.Mean.Sum | D.SD.Sum | D.Rat.Sum | ... | A.Rat.L | A.Mean.H | A.SD.H | A.Rat.H | D.Mean.L | D.SD.L | D.Rat.L | D.Mean.H | D.SD.H | D.Rat.H | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | aardvark | 6.26 | 2.21 | 19 | 2.41 | 1.40 | 22 | 4.27 | 1.75 | 15 | ... | 11 | 2.55 | 1.29 | 11 | 4.12 | 1.64 | 8 | 4.43 | 1.99 | 7 |
1 | abalone | 5.30 | 1.59 | 20 | 2.65 | 1.90 | 20 | 4.95 | 1.79 | 22 | ... | 12 | 2.38 | 1.92 | 8 | 5.55 | 2.21 | 11 | 4.36 | 1.03 | 11 |
2 | abandon | 2.84 | 1.54 | 19 | 3.73 | 2.43 | 22 | 3.32 | 2.50 | 22 | ... | 11 | 3.82 | 2.14 | 11 | 2.77 | 2.09 | 13 | 4.11 | 2.93 | 9 |
3 | abandonment | 2.63 | 1.74 | 19 | 4.95 | 2.64 | 21 | 2.64 | 1.81 | 28 | ... | 14 | 5.29 | 2.63 | 7 | 2.31 | 1.45 | 16 | 3.08 | 2.19 | 12 |
4 | abbey | 5.85 | 1.69 | 20 | 2.20 | 1.70 | 20 | 5.00 | 2.02 | 25 | ... | 9 | 2.55 | 1.92 | 11 | 4.83 | 2.18 | 18 | 5.43 | 1.62 | 7 |
5 | abdomen | 5.43 | 1.75 | 21 | 3.68 | 2.23 | 22 | 5.15 | 1.94 | 27 | ... | 10 | 4.17 | 1.70 | 12 | 5.93 | 1.90 | 14 | 4.31 | 1.65 | 13 |
6 | abdominal | 4.48 | 1.59 | 23 | 3.50 | 1.82 | 22 | 5.32 | 2.11 | 19 | ... | 12 | 3.90 | 1.60 | 10 | 6.50 | 1.52 | 6 | 4.77 | 2.17 | 13 |
7 | abduct | 2.42 | 1.61 | 19 | 5.90 | 2.57 | 20 | 2.75 | 2.13 | 24 | ... | 10 | 6.40 | 2.50 | 10 | 2.89 | 2.52 | 9 | 2.67 | 1.95 | 15 |
8 | abduction | 2.05 | 1.31 | 19 | 5.33 | 2.20 | 21 | 3.02 | 2.42 | 48 | ... | 10 | 5.00 | 2.72 | 11 | 3.03 | 2.39 | 30 | 3.00 | 2.54 | 18 |
9 | abide | 5.52 | 1.75 | 21 | 3.26 | 2.22 | 23 | 5.33 | 2.83 | 18 | ... | 11 | 3.67 | 2.39 | 12 | 3.44 | 2.24 | 9 | 7.22 | 1.99 | 9 |
10 | abiding | 5.57 | 1.75 | 23 | 3.59 | 2.26 | 22 | 6.60 | 2.30 | 20 | ... | 10 | 3.58 | 2.27 | 12 | 6.30 | 2.16 | 10 | 6.90 | 2.51 | 10 |
11 | ability | 7.00 | 1.59 | 20 | 4.85 | 2.74 | 20 | 6.55 | 2.48 | 22 | ... | 13 | 5.43 | 2.99 | 7 | 7.00 | 2.59 | 12 | 6.00 | 2.36 | 10 |
12 | abject | 4.00 | 1.29 | 19 | 3.94 | 2.41 | 17 | 4.35 | 2.60 | 17 | ... | 11 | 5.33 | 2.42 | 6 | 4.57 | 2.99 | 7 | 4.20 | 2.44 | 10 |
13 | ablaze | 5.15 | 1.79 | 20 | 6.75 | 2.12 | 20 | 4.58 | 2.39 | 36 | ... | 11 | 6.67 | 2.40 | 9 | 4.36 | 2.57 | 22 | 4.93 | 2.13 | 14 |
14 | able | 6.64 | 1.79 | 22 | 3.38 | 2.25 | 21 | 6.17 | 2.62 | 18 | ... | 6 | 3.27 | 2.09 | 15 | 7.30 | 1.95 | 10 | 4.75 | 2.76 | 8 |
15 | abnormal | 3.53 | 1.22 | 19 | 4.48 | 2.29 | 21 | 4.70 | 2.44 | 23 | ... | 10 | 3.64 | 2.42 | 11 | 4.85 | 3.00 | 13 | 4.50 | 1.58 | 10 |
16 | abnormality | 3.05 | 1.81 | 19 | 5.00 | 2.62 | 22 | 3.96 | 2.50 | 23 | ... | 11 | 6.00 | 2.00 | 11 | 3.77 | 2.42 | 13 | 4.20 | 2.70 | 10 |
17 | abode | 5.28 | 1.27 | 18 | 2.90 | 1.89 | 21 | 5.05 | 2.44 | 20 | ... | 9 | 3.17 | 1.80 | 12 | 4.62 | 3.16 | 8 | 5.33 | 1.92 | 12 |
18 | abolish | 3.84 | 1.54 | 19 | 4.18 | 2.07 | 17 | 4.65 | 2.42 | 17 | ... | 10 | 5.00 | 1.91 | 7 | 5.57 | 3.21 | 7 | 4.00 | 1.56 | 10 |
19 | abominable | 4.05 | 1.23 | 20 | 5.45 | 2.44 | 22 | 4.62 | 1.83 | 21 | ... | 12 | 6.30 | 2.16 | 10 | 4.67 | 1.83 | 12 | 4.56 | 1.94 | 9 |
20 | abomination | 2.50 | 1.65 | 18 | 5.90 | 2.59 | 20 | 3.80 | 1.38 | 25 | ... | 11 | 6.22 | 1.79 | 9 | 4.00 | 1.25 | 19 | 3.17 | 1.72 | 6 |
21 | abort | 3.10 | 1.37 | 20 | 5.80 | 2.44 | 20 | 3.38 | 2.21 | 26 | ... | 12 | 5.50 | 2.39 | 8 | 3.25 | 1.84 | 16 | 3.60 | 2.80 | 10 |
22 | abortion | 2.58 | 1.84 | 19 | 5.43 | 2.38 | 47 | 4.73 | 2.95 | 44 | ... | 25 | 5.77 | 2.39 | 22 | 4.16 | 3.10 | 25 | 5.47 | 2.63 | 19 |
23 | abracadabra | 5.11 | 2.52 | 18 | 5.27 | 2.64 | 22 | 4.96 | 1.97 | 24 | ... | 9 | 4.54 | 2.76 | 13 | 4.94 | 2.05 | 16 | 5.00 | 1.93 | 8 |
24 | abrasive | 4.26 | 1.69 | 19 | 6.10 | 1.89 | 21 | 4.94 | 2.32 | 34 | ... | 14 | 6.29 | 1.50 | 7 | 5.88 | 2.34 | 17 | 4.00 | 1.94 | 17 |
25 | abreast | 4.62 | 1.94 | 21 | 4.61 | 2.33 | 23 | 5.19 | 1.99 | 21 | ... | 19 | 3.25 | 2.06 | 4 | 5.07 | 1.69 | 14 | 5.43 | 2.64 | 7 |
26 | abrupt | 3.28 | 1.64 | 18 | 5.23 | 2.00 | 22 | 3.75 | 1.80 | 24 | ... | 9 | 5.92 | 2.14 | 13 | 4.06 | 1.81 | 16 | 3.12 | 1.73 | 8 |
27 | abscess | 2.79 | 1.58 | 19 | 4.00 | 2.38 | 20 | 3.95 | 2.31 | 20 | ... | 10 | 3.90 | 2.18 | 10 | 3.56 | 1.81 | 9 | 4.27 | 2.69 | 11 |
28 | absence | 3.86 | 2.08 | 21 | 4.30 | 2.13 | 20 | 4.24 | 2.32 | 21 | ... | 14 | 4.00 | 1.67 | 6 | 3.17 | 2.29 | 12 | 5.67 | 1.50 | 9 |
29 | absent | 4.10 | 1.55 | 21 | 3.72 | 2.48 | 25 | 4.21 | 2.37 | 19 | ... | 16 | 2.67 | 2.12 | 9 | 4.27 | 2.72 | 11 | 4.12 | 1.96 | 8 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
13885 | young | 6.31 | 1.59 | 39 | 4.09 | 2.22 | 22 | 5.60 | 2.84 | 58 | ... | 10 | 3.67 | 2.23 | 12 | 6.12 | 2.78 | 32 | 4.96 | 2.84 | 26 |
13886 | youngster | 6.05 | 1.72 | 21 | 4.55 | 2.19 | 20 | 5.00 | 2.55 | 21 | ... | 14 | 3.33 | 1.03 | 6 | 5.25 | 2.73 | 12 | 4.67 | 2.40 | 9 |
13887 | youth | 6.53 | 1.58 | 19 | 4.14 | 2.58 | 44 | 5.00 | 2.05 | 48 | ... | 30 | 4.57 | 2.79 | 14 | 5.50 | 2.21 | 26 | 4.41 | 1.71 | 22 |
13888 | youthful | 6.89 | 1.97 | 19 | 5.68 | 2.50 | 22 | 6.00 | 2.28 | 23 | ... | 11 | 5.45 | 2.25 | 11 | 5.92 | 2.53 | 13 | 6.10 | 2.02 | 10 |
13889 | yucky | 3.36 | 2.01 | 22 | 4.35 | 2.58 | 20 | 4.36 | 2.52 | 22 | ... | 12 | 4.50 | 2.14 | 8 | 5.00 | 2.41 | 12 | 3.60 | 2.55 | 10 |
13890 | yuletide | 6.19 | 1.99 | 21 | 4.00 | 2.24 | 19 | 5.08 | 2.10 | 25 | ... | 12 | 4.14 | 2.61 | 7 | 4.78 | 2.11 | 9 | 5.25 | 2.14 | 16 |
13891 | yummy | 7.52 | 1.94 | 21 | 4.48 | 2.50 | 25 | 6.84 | 2.06 | 19 | ... | 16 | 3.33 | 2.55 | 9 | 7.09 | 2.30 | 11 | 6.50 | 1.77 | 8 |
13892 | yuppie | 4.64 | 2.48 | 22 | 4.65 | 2.37 | 20 | 5.39 | 1.85 | 23 | ... | 10 | 5.30 | 1.34 | 10 | 5.25 | 2.55 | 8 | 5.47 | 1.46 | 15 |
13893 | zap | 5.39 | 2.52 | 18 | 4.41 | 2.44 | 22 | 4.87 | 2.63 | 23 | ... | 11 | 5.36 | 2.34 | 11 | 5.31 | 2.75 | 13 | 4.30 | 2.50 | 10 |
13894 | zeal | 6.15 | 2.08 | 20 | 5.33 | 2.71 | 21 | 5.59 | 2.35 | 34 | ... | 14 | 5.86 | 2.97 | 7 | 5.18 | 1.98 | 17 | 6.00 | 2.67 | 17 |
13895 | zebra | 6.47 | 2.34 | 19 | 3.90 | 2.75 | 20 | 5.26 | 2.23 | 19 | ... | 10 | 3.70 | 2.87 | 10 | 3.89 | 2.20 | 9 | 6.50 | 1.43 | 10 |
13896 | zenith | 5.20 | 1.79 | 20 | 3.71 | 2.12 | 24 | 5.36 | 2.09 | 28 | ... | 12 | 4.00 | 2.30 | 12 | 5.33 | 1.30 | 12 | 5.38 | 2.58 | 16 |
13897 | zephyr | 5.50 | 1.50 | 20 | 3.41 | 2.20 | 22 | 5.22 | 2.50 | 27 | ... | 16 | 3.83 | 2.23 | 6 | 4.67 | 2.81 | 12 | 5.67 | 2.23 | 15 |
13898 | zest | 6.76 | 1.53 | 41 | 5.41 | 2.44 | 22 | 6.58 | 1.79 | 26 | ... | 9 | 5.77 | 2.98 | 13 | 6.19 | 1.80 | 16 | 7.20 | 1.69 | 10 |
13899 | zeta | 5.55 | 0.94 | 20 | 3.75 | 2.20 | 20 | 5.20 | 2.02 | 25 | ... | 12 | 3.00 | 2.00 | 8 | 5.67 | 1.63 | 15 | 4.50 | 2.42 | 10 |
13900 | zigzag | 5.18 | 1.30 | 22 | 5.42 | 2.34 | 19 | 5.00 | 2.21 | 21 | ... | 8 | 6.36 | 1.75 | 11 | 4.56 | 1.59 | 9 | 5.33 | 2.61 | 12 |
13901 | zilch | 3.89 | 1.78 | 18 | 4.05 | 2.21 | 20 | 4.25 | 1.96 | 24 | ... | 11 | 3.67 | 2.78 | 9 | 4.72 | 1.81 | 18 | 2.83 | 1.83 | 6 |
13902 | zillion | 5.81 | 2.23 | 21 | 4.26 | 2.83 | 23 | 4.89 | 2.72 | 18 | ... | 11 | 3.50 | 2.39 | 12 | 3.78 | 2.17 | 9 | 6.00 | 2.87 | 9 |
13903 | zinc | 4.79 | 1.65 | 19 | 3.17 | 2.04 | 18 | 5.00 | 2.15 | 17 | ... | 11 | 4.00 | 2.08 | 7 | 5.00 | 2.00 | 7 | 5.00 | 2.36 | 10 |
13904 | zing | 6.95 | 1.90 | 19 | 4.81 | 2.69 | 21 | 6.36 | 1.97 | 22 | ... | 8 | 4.54 | 2.50 | 13 | 6.86 | 2.03 | 14 | 5.50 | 1.60 | 8 |
13905 | zip | 5.06 | 1.35 | 18 | 4.24 | 2.23 | 21 | 4.67 | 2.28 | 18 | ... | 9 | 4.92 | 2.31 | 12 | 4.33 | 2.34 | 6 | 4.83 | 2.33 | 12 |
13906 | zipper | 5.11 | 2.13 | 19 | 3.73 | 2.21 | 22 | 5.18 | 2.15 | 22 | ... | 11 | 4.09 | 2.12 | 11 | 4.77 | 2.20 | 13 | 5.78 | 2.05 | 9 |
13907 | zit | 3.30 | 1.49 | 20 | 4.29 | 2.43 | 21 | 4.40 | 2.97 | 25 | ... | 11 | 3.80 | 2.74 | 10 | 4.44 | 3.33 | 18 | 4.29 | 1.98 | 7 |
13908 | zodiac | 5.55 | 1.99 | 20 | 4.25 | 2.51 | 20 | 4.32 | 2.08 | 22 | ... | 12 | 3.62 | 2.56 | 8 | 4.82 | 2.40 | 11 | 3.82 | 1.66 | 11 |
13909 | zombie | 3.57 | 2.46 | 21 | 6.53 | 1.95 | 19 | 3.57 | 2.46 | 21 | ... | 13 | 5.67 | 0.82 | 6 | 2.75 | 2.42 | 12 | 4.67 | 2.18 | 9 |
13910 | zone | 4.75 | 2.05 | 20 | 3.78 | 2.53 | 18 | 5.23 | 1.82 | 22 | ... | 9 | 4.89 | 1.76 | 9 | 5.09 | 1.81 | 11 | 5.36 | 1.91 | 11 |
13911 | zoning | 4.65 | 1.60 | 20 | 3.77 | 1.95 | 22 | 4.47 | 2.20 | 19 | ... | 12 | 3.70 | 1.57 | 10 | 5.17 | 2.32 | 6 | 4.15 | 2.15 | 13 |
13912 | zoo | 7.00 | 1.58 | 21 | 5.63 | 2.54 | 19 | 6.33 | 2.56 | 21 | ... | 13 | 5.17 | 2.14 | 6 | 5.67 | 2.87 | 12 | 7.22 | 1.86 | 9 |
13913 | zoom | 5.86 | 1.53 | 21 | 5.68 | 2.54 | 19 | 5.90 | 2.17 | 21 | ... | 8 | 6.27 | 2.45 | 11 | 6.00 | 2.12 | 9 | 5.83 | 2.29 | 12 |
13914 | zucchini | 6.30 | 2.36 | 20 | 4.18 | 2.20 | 22 | 6.19 | 1.83 | 21 | ... | 12 | 4.60 | 2.46 | 10 | 6.33 | 1.87 | 12 | 6.00 | 1.87 | 9 |
13915 rows × 64 columns
# WTF do the keys mean?
from collections import defaultdict
k_d = defaultdict(set)
for striped in [k.split('.') for k in df.keys()]:
if len(striped) > 1:
dim, measure, sub = striped
k_d[measure].update(sub)
k_d
defaultdict(set, {'Mean': {'F', 'H', 'L', 'M', 'O', 'S', 'Y', 'm', 'u'}, 'SD': {'F', 'H', 'L', 'M', 'O', 'S', 'Y', 'm', 'u'}, 'Rat': {'F', 'H', 'L', 'M', 'O', 'S', 'Y', 'm', 'u'}})
# From http://crr.ugent.be/papers/Warriner_et_al_affective_ratings.pdf
key_map = {
'M':'Male',
'F':'Female',
'H': 'High Education (Degree or higher)',
'L': 'Low Education (Partial degree or lower)',
'Y': 'Younger',
'O': 'Older',
'm': 'm',
'u': 'u'
}
%matplotlib notebook
import matplotlib as mpl
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
targets=['V.Mean.Sum','A.Mean.Sum','D.Mean.Sum']
v,a,d = df[targets].values.T
ax.scatter(v,a,d)
<mpl_toolkits.mplot3d.art3d.Path3DCollection at 0x123dc8ba8>
from scipy.spatial.distance import pdist, squareform
from scipy.cluster.hierarchy import linkage, dendrogram
row_clusters = linkage(pdist(df[targets], metric='euclidean'), method='complete')
f,ax = plt.subplots(figsize=(16,44))
row_dendr = dendrogram(row_clusters,
labels=df['Word'].values,
orientation='right'
)
f.tight_layout()
ax.set_ylabel('Distance')
f.savefig('WarrinerDendrogram.png')
from sklearn.cluster import AgglomerativeClustering
ac = AgglomerativeClustering(n_clusters=3, affinity='euclidean', linkage='complete')
labels = ac.fit_predict(df[targets].values)
df['label'] = labels
df.groupby('label')[targets].mean()
V.Mean.Sum | A.Mean.Sum | D.Mean.Sum | |
---|---|---|---|
label | |||
0 | 5.500630 | 3.656419 | 5.437269 |
1 | 3.387172 | 4.839974 | 4.007651 |
2 | 5.655209 | 4.926557 | 5.730107 |
colors = ['b','r','g']
df['label_color'] = df['label'].apply(lambda l: colors[l])
sample_words = """
Stress
Intoxication
Fatigue
Positivity
Negativity
Emotionality
Focus
Activity
Engagement
Arousal
Excitement
Dominance
Valence
Affection
Anger
Boredom
Contentment
Depression
Disgust
Enthusiasm
Excitement
Fear
Frustration
Happiness
Interest
Joy
Nervousness
Panic
Pride
Relaxation
Sadness
Surprise
Satisfaction
Tension
Worry
Activation""".lower().split()
df['in_sample'] = df['Word'].isin(sample_words)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
targets=['V.Mean.Sum','A.Mean.Sum','D.Mean.Sum', 'label_color']
v,a,d,c = df[targets].values.T
ax.scatter(v,a,d,c=c, alpha=0.4)
ax.set_xlabel('Valence')
ax.set_ylabel('Arousal')
ax.set_zlabel('Dominance')
for w in sample_words:
try:
v,a,d,c = df[df['Word']==w][targets].values[0]
ax.text(v,a,d,w, zorder=1, bbox=dict(facecolor=c, alpha=0.5))
except (KeyError, IndexError):
pass
except:
raise
import cufflinks
import plotly
df.iplot(kind='scatter3d',
x=targets[0], xTitle='Valence',
y=targets[1], yTitle='Arousal',
z=targets[2], zTitle='Dominance', width=0,
categories='label_color',
size=2, mode='markers', symbol='circle', text='Word',)
/Users/andrew.bolster/anaconda3/envs/datasci/lib/python3.6/site-packages/plotly/graph_objs/_deprecations.py:558: DeprecationWarning: plotly.graph_objs.YAxis is deprecated. Please replace it with one of the following more specific types - plotly.graph_objs.layout.YAxis - plotly.graph_objs.layout.scene.YAxis /Users/andrew.bolster/anaconda3/envs/datasci/lib/python3.6/site-packages/plotly/graph_objs/_deprecations.py:531: DeprecationWarning: plotly.graph_objs.XAxis is deprecated. Please replace it with one of the following more specific types - plotly.graph_objs.layout.XAxis - plotly.graph_objs.layout.scene.XAxis
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-10-d432e22e4da6> in <module> 7 z=targets[2], zTitle='Dominance', width=0, 8 categories='label_color', ----> 9 size=2, mode='markers', symbol='circle', text='Word',) ~/anaconda3/envs/datasci/lib/python3.6/site-packages/cufflinks/plotlytools.py in _iplot(self, kind, data, layout, filename, sharing, title, xTitle, yTitle, zTitle, theme, colors, colorscale, fill, width, dash, mode, interpolation, symbol, size, barmode, sortbars, bargap, bargroupgap, bins, histnorm, histfunc, orientation, boxpoints, annotations, keys, bestfit, bestfit_colors, mean, mean_colors, categories, x, y, z, text, gridcolor, zerolinecolor, margin, labels, values, secondary_y, secondary_y_title, subplots, shape, error_x, error_y, error_type, locations, lon, lat, asFrame, asDates, asFigure, asImage, dimensions, asPlot, asUrl, online, **kwargs) 761 bargap=bargap,bargroupgap=bargroupgap,annotations=annotations,gridcolor=gridcolor, 762 dimensions=dimensions, --> 763 zerolinecolor=zerolinecolor,margin=margin,is3d='3d' in kind,**l_kwargs) 764 765 if not data: ~/anaconda3/envs/datasci/lib/python3.6/site-packages/cufflinks/tools.py in getLayout(kind, theme, title, xTitle, yTitle, zTitle, barmode, bargap, bargroupgap, margin, dimensions, width, height, annotations, is3d, **kwargs) 199 200 theme_data = getTheme(theme) --> 201 layout=go.Layout(theme_data['layout']) 202 layout['xaxis1'].update({'title':xTitle}) 203 layout['yaxis1'].update({'title':yTitle}) ~/anaconda3/envs/datasci/lib/python3.6/site-packages/plotly/graph_objs/_layout.py in __init__(self, arg, angularaxis, annotations, annotationdefaults, autosize, bargap, bargroupgap, barmode, barnorm, boxgap, boxgroupgap, boxmode, calendar, clickmode, colorway, datarevision, direction, dragmode, extendpiecolors, font, geo, grid, height, hiddenlabels, hiddenlabelssrc, hidesources, hoverdistance, hoverlabel, hovermode, images, imagedefaults, legend, mapbox, margin, modebar, orientation, paper_bgcolor, piecolorway, plot_bgcolor, polar, radialaxis, scene, selectdirection, separators, shapes, shapedefaults, showlegend, sliders, sliderdefaults, spikedistance, template, ternary, title, titlefont, updatemenus, updatemenudefaults, violingap, violingroupgap, violinmode, width, xaxis, yaxis, **kwargs) 4278 ] = imagedefaults if imagedefaults is not None else _v 4279 _v = arg.pop('legend', None) -> 4280 self['legend'] = legend if legend is not None else _v 4281 _v = arg.pop('mapbox', None) 4282 self['mapbox'] = mapbox if mapbox is not None else _v ~/anaconda3/envs/datasci/lib/python3.6/site-packages/plotly/basedatatypes.py in __setitem__(self, prop, value) 3716 if match is None: 3717 # Set as ordinary property -> 3718 super(BaseLayoutHierarchyType, self).__setitem__(prop, value) 3719 else: 3720 # Set as subplotid property ~/anaconda3/envs/datasci/lib/python3.6/site-packages/plotly/basedatatypes.py in __setitem__(self, prop, value) 2788 # ### Handle compound property ### 2789 if isinstance(validator, CompoundValidator): -> 2790 self._set_compound_prop(prop, value) 2791 2792 # ### Handle compound array property ### ~/anaconda3/envs/datasci/lib/python3.6/site-packages/plotly/basedatatypes.py in _set_compound_prop(self, prop, val) 3092 validator = self._validators.get(prop) 3093 # type: BasePlotlyType -> 3094 val = validator.validate_coerce(val, skip_invalid=self._skip_invalid) 3095 3096 # Save deep copies of current and new states ~/anaconda3/envs/datasci/lib/python3.6/site-packages/_plotly_utils/basevalidators.py in validate_coerce(self, v, skip_invalid) 2093 2094 elif isinstance(v, dict): -> 2095 v = self.data_class(v, skip_invalid=skip_invalid) 2096 2097 elif isinstance(v, self.data_class): ~/anaconda3/envs/datasci/lib/python3.6/site-packages/plotly/graph_objs/layout/_legend.py in __init__(self, arg, bgcolor, bordercolor, borderwidth, font, orientation, tracegroupgap, traceorder, x, xanchor, y, yanchor, **kwargs) 504 # ---------------------------------- 505 _v = arg.pop('bgcolor', None) --> 506 self['bgcolor'] = bgcolor if bgcolor is not None else _v 507 _v = arg.pop('bordercolor', None) 508 self['bordercolor'] = bordercolor if bordercolor is not None else _v ~/anaconda3/envs/datasci/lib/python3.6/site-packages/plotly/basedatatypes.py in __setitem__(self, prop, value) 2797 # ### Handle simple property ### 2798 else: -> 2799 self._set_prop(prop, value) 2800 2801 # Handle non-scalar case ~/anaconda3/envs/datasci/lib/python3.6/site-packages/plotly/basedatatypes.py in _set_prop(self, prop, val) 3033 return 3034 else: -> 3035 raise err 3036 3037 # val is None ~/anaconda3/envs/datasci/lib/python3.6/site-packages/plotly/basedatatypes.py in _set_prop(self, prop, val) 3028 validator = self._validators.get(prop) 3029 try: -> 3030 val = validator.validate_coerce(val) 3031 except ValueError as err: 3032 if self._skip_invalid: ~/anaconda3/envs/datasci/lib/python3.6/site-packages/_plotly_utils/basevalidators.py in validate_coerce(self, v, should_raise) 1126 validated_v = self.vc_scalar(v) 1127 if validated_v is None and should_raise: -> 1128 self.raise_invalid_val(v) 1129 1130 v = validated_v ~/anaconda3/envs/datasci/lib/python3.6/site-packages/_plotly_utils/basevalidators.py in raise_invalid_val(self, v, inds) 252 typ=type_str(v), 253 v=repr(v), --> 254 valid_clr_desc=self.description())) 255 256 def raise_invalid_elements(self, invalid_els): ValueError: Invalid value of type 'builtins.str' received for the 'bgcolor' property of layout.legend Received value: 'pearl02' The 'bgcolor' property is a color and may be specified as: - A hex string (e.g. '#ff0000') - An rgb/rgba string (e.g. 'rgb(255,0,0)') - An hsl/hsla string (e.g. 'hsl(0,100%,50%)') - An hsv/hsva string (e.g. 'hsv(0,100%,100%)') - A named CSS color: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen